<template>
  <el-dialog title="添加法条" :visible.sync="dialogVisible" @opened="dialogOpen">
    <el-form ref="form" :model="form" label-width="80px" size="small">
      <el-form-item prop="strName" label="法规名称">
        <el-input v-model="form.strName" disabled="disabled"></el-input>
      </el-form-item>
      <el-form-item prop="code" label="法条编码">
        <el-input v-model="form.code"></el-input>
      </el-form-item>
      <el-form-item prop="item" label="条">
        <el-input v-model="form.item"></el-input>
      </el-form-item>
      <el-form-item prop="yjtl" label="违反条例">
        <el-input v-model="form.yjtl"></el-input>
      </el-form-item>
      <el-form-item prop="upperLimit" label="罚款上限">
        <el-input v-model="form.upperLimit"></el-input>
      </el-form-item>
      <el-form-item prop="lawerLimit" label="罚款下限">
        <el-input v-model="form.lawerLimit"></el-input>
      </el-form-item>
      <el-form-item prop="cfbz" label="处罚标准">
        <el-input type="textarea" v-model="form.cfbz"></el-input>

      </el-form-item>
      <el-form-item>
        <el-button type="primary" :loading="loading" @click="saveUser">保存</el-button>
        <el-button @click="close">取消</el-button>
        <!--<el-button
          @click="saveUser"
       style="display:inline-block;width:52px;height:27px;background-color:#409EFF;color:#fff;line-height:27px;">保存</el-button>
        <el-button @click="close"style="display:inline-block;width:52px;height:27px;line-height:27px;border:1px solid #DCDFE6">取消</el-button>-->
      </el-form-item>
    </el-form>
  </el-dialog>
</template>
<script>
import itemsApi from "@/api/system/caseCauselawcontent";
export default {
  name: "AddForm",
  props: {
    temp: Object,
    value: Boolean
  },
  data() {
    return {
      loading: false,
      dialogVisible: false,
      form: {
        code: "",
        strName: "",
        item: "",
        yjtl: "",
        upperLimit: "",
        lawerLimit: "",
        cfbz: "",
        lawContentId: ""
      }
    };
  },
  watch: {
    value(val) {
      this.dialogVisible = val;
    },
    dialogVisible(val) {
      this.$emit("input", val);
    }
  },
  methods: {
    dialogOpen() {
      this.$refs.form.resetFields();

      this.form.lawContentId = this.temp.lawContentId;
      this.form.strName = this.temp.strName;
    },
    saveUser() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.loading = true;
          itemsApi.add({ ...this.form }).then(data => {
            this.loading = false;
            this.dialogVisible = false;
            this.$emit("submit");
          });
        } else {
          return false;
        }
      });
    },
    close() {
      this.$refs["form"].resetFields();
      this.dialogVisible = false;
    }
  }
};
</script>

